package com.vichat.user.service.impl;

import com.vichat.common.util.NumberUtils;
import com.vichat.common.vo.PageFilter;
import com.vichat.core.dao.BaseDaoI;
import com.vichat.user.entity.I18nMapping;
import com.vichat.user.service.II18nMappingService;
import com.vichat.user.service.II18nMappingService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by user on 2016/11/17.
 */
@Service("i18nMappingService")
public class I18nMappingServiceImpl implements II18nMappingService {

    @Autowired
    private BaseDaoI<I18nMapping> systemMessageDao;


    /**
     * 获取系统参数数量
     *
     * @param queryBean
     * @return
     * @throws Exception
     */
    public Long countI18nMapping(I18nMapping queryBean) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        String hql = "select count(*) from I18nMapping where state = 1";
        return systemMessageDao.count(hql , params);
    }

    /**
     * 查询系统参数
     *
     * @param queryBean
     * @return
     * @throws Exception
     */
    public List<I18nMapping> queryI18nMapping(I18nMapping queryBean, PageFilter pf) throws Exception {
        HashMap params = new HashMap();
        String hql = "from I18nMapping where state = 1";
        long lastMsgId = 0;

        List<I18nMapping> systemMessageList = systemMessageDao.find(hql + " order by mapId desc ", params, pf.getPage(), pf.getRows());
        return systemMessageList;
    }


    /**
     * 根据编号获取系统参数
     *
     * @param msgId
     * @return
     */
    public I18nMapping queryI18nMappingByMsgId(long msgId) {
        I18nMapping sysStaticDataFDB = systemMessageDao.get(I18nMapping.class, msgId);
        return sysStaticDataFDB;
    }

}
